﻿//<TunynetCopyright>
//--------------------------------------------------------------
//<copyright>青岛拓宇网络科技有限公司 2005-2008</copyright>
//<version>V0.5</verion>
//<createdate>2008-4-5</createdate>
//<author>mazq</author>
//<email>mazq@tunynet.com</email>
//<log date="2008-4-5">创建</log>
//--------------------------------------------------------------
//</TunynetCopyright>

using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using ChinaCustoms.Qingdao.Workflow.Supports;
using System.Web.UI.WebControls;

namespace ChinaCustoms.Qingdao.Workflow.Controls
{
    /// <summary>
    /// 封装工作流流转相关数据
    /// </summary>
    public class WorkflowEventArgs : EventArgs
    {
        ///// <summary>
        ///// 构造函数
        ///// </summary>
        //public WorkflowEventArgs()
        //{ }

        /// <summary>
        /// 构造函数
        /// </summary>
        public WorkflowEventArgs(WorkItemInfo currentWorkItem)
        {
            this.currentWorkItem = currentWorkItem;
        }

        /// <summary>
        /// 构造函数
        /// </summary>
        public WorkflowEventArgs(WorkItemInfo currentWorkItem, ActivityPrototypeInfo nextActivityPrototype)
        {
            this.currentWorkItem = currentWorkItem;
            this.nextActivityPrototype = nextActivityPrototype;
        }

        /// <summary>
        /// 构造函数
        /// </summary>
        public WorkflowEventArgs(WorkItemInfo currentWorkItem, ActivityInstanceInfo currentActivityInstance, ActivityPrototypeInfo nextActivityPrototype)
        {
            this.currentWorkItem = currentWorkItem;
            this.currentActivityInstance = currentActivityInstance;
            this.nextActivityPrototype = nextActivityPrototype;
        }

        private WorkItemInfo currentWorkItem = null;
        /// <summary>
        /// 当前工作项
        /// </summary>
        public WorkItemInfo CurrentWorkItem
        {
            get { return currentWorkItem; }
            set { currentWorkItem = value; }
        }

        private ActivityInstanceInfo currentActivityInstance = null;
        /// <summary>
        /// 当前活动实例
        /// </summary>
        public ActivityInstanceInfo CurrentActivityInstance
        {
            get
            {
                if (currentActivityInstance == null)
                {
                    if (this.currentWorkItem == null)
                    {
                        currentActivityInstance = null;
                    }
                    else
                    {
                        currentActivityInstance = this.currentWorkItem.Activity;
                    }
                }

                return currentActivityInstance;
            }
            set { currentActivityInstance = value; }
        }

        private ActivityPrototypeInfo nextActivityPrototype = null;
        /// <summary>
        /// 下一活动原型
        /// </summary>
        public ActivityPrototypeInfo NextActivityPrototype
        {
            get
            {
                // TODO 是否根据当前活动获取下一个活动原型，进一步讨论
                //if (nextActivityPrototype == null)
                //    this.nextActivityPrototype = ActivityPrototypes.GetNextActivityPrototype(this.CurrentActivityInstance.WorkflowGuid,this.CurrentActivityInstance.SubFlowGuid, this.CurrentActivityInstance.CodeName);

                return nextActivityPrototype;
            }
            set { nextActivityPrototype = value; }
        }


        private bool isCanceled = false;
        /// <summary>
        /// 是否取消下一步操作
        /// </summary>
        public bool IsCancelled
        {
            get { return isCanceled; }
            set { isCanceled = value; }
        }


    }

    /// <summary>
    /// 处理工作流流转相关事件
    /// </summary>
    /// <param name="sender">事件源</param>
    /// <param name="e">事件数据</param>
    public delegate void WorkflowEventHandler(object sender, WorkflowEventArgs e);

    /// <summary>
    /// 处理工作流下一步跳转选项的事件
    /// </summary>
    /// <param name="sender"></param>
    public delegate void WorkflowChangeNextStepEventHandler(object sender,WorkflowChangeNextStepEventArgs e);

    /// <summary>
    /// 工作流下一步跳转选项的参数
    /// </summary>
    public class WorkflowChangeNextStepEventArgs : EventArgs
    {
        public WorkflowChangeNextStepEventArgs(ListItemCollection itemList)
        {
            this.itemList = itemList;
        }

        private ListItemCollection originalItemList;
        /// <summary>
        /// 原始的跳转选项列表
        /// </summary>
        public ListItemCollection OriginalItemList
        {
            get { return originalItemList; }
            set { originalItemList = value; }
        }
	

        private ListItemCollection itemList = null;
        /// <summary>
        /// 可供跳转的选择项列表
        /// </summary>
        public ListItemCollection ItemList 
        {
            get { return this.itemList; }
            set { this.itemList = value; }
        }

        private bool isDealed= false;
        /// <summary>
        /// 参数是否经过处理
        /// </summary>
        public bool IsDealed
        {
            get { return isDealed; }
            set { isDealed = value; }
        }

    }
}
